jQuery(document).ready(function(){
	initMap();//初始化google map
});
var map;
var marker;
//存储植物地理位置，得到初始化地图后再标志出这些地理位置
var longitudes = new Array();
var latitudes = new Array();
var count = 0;//地理位置的数量
/**
 * 初始化地图
 * @return
 */
function initMap()
{
	var latlng = new google.maps.LatLng(24.437736364171066,118.09754759073257);
	map = new google.maps.Map(document.getElementById('map'), {  
	    zoom: 14,  
	    center: latlng,  
	    mapTypeId: google.maps.MapTypeId.ROADMAP  
	});
//	google.maps.event.addListener(map, 'click', function(event) {
//	    placeMarker(event.latLng);
//	});
	var sw =  new google.maps.LatLng(24.429128461693962,118.07772142648697);
	var ne =  new google.maps.LatLng(24.45523099834168,118.1123082947731);
	//自定义地图的显示范围:厦大周边  
	var strictBounds = new google.maps.LatLngBounds(  
	    sw, ne);  
	google.maps.event.addListener(map, 'dragend',  
	function() {  
	    if (strictBounds.contains(map.getCenter())) return;  
	    var c = map.getCenter(),  
	    x = c.lng(),  
	    y = c.lat(),  
	    maxX = strictBounds.getNorthEast().lng(),  
	    maxY = strictBounds.getNorthEast().lat(),  
	    minX = strictBounds.getSouthWest().lng(),  
	    minY = strictBounds.getSouthWest().lat();  
	    if (x < minX) x = minX;  
	    if (x > maxX) x = maxX;  
	    if (y < minY) y = minY;  
	    if (y > maxY) y = maxY;  
	    map.setCenter(new google.maps.LatLng(y, x));  
	});
	//在地图上标记处植物地理位置
	for(var i=0; i<count; i++)
	{
		placeMarker(longitudes[i],latitudes[i]);
	}
}
/**
 * 放置一个图标在地图上
 * @param location
 * @return
 */
function placeMarker(longitude, latitude) {
	var lng = Number(longitude);
	var lat = Number(latitude);
	var location = new google.maps.LatLng(lat,lng);

	marker = new google.maps.Marker( {
		position : location,
		map : map
	});
	
}
/**
 * 先存储地理位置
 * @param longitude
 * @param latitude
 * @return
 */
function storeLocation(longitude, latitude){
	longitudes[count] = longitude;
	latitudes[count] = latitude;
	count++;
}
function sure(){
	var plantId = document.getElementById("plantId").value;
	location.href='plantManager-deletePlant.html?plantId=' + plantId;
}